﻿@page "/user_center/tenant"
@inherits ListOperateTableBase<SystemTenantDto, Guid, TenantEdit,UserCenterResource>
<div>
    <Table @ref="_table"
           TItem="SystemTenantDto"
           DataSource="_datas"
           Total="_total"
           OnChange="OnChange"
           @bind-PageSize="_pageSize"
           @bind-PageIndex="_pageIndex"
           @bind-SelectedRows="_selectedRows"
           Loading="_tableLoading.Value"
           Context="model"
           Size="ClientConstant.DefaultTableSize"
           PaginationPosition="@ClientConstant.TablePaginationPosition"
           RemoteDataSource>
        <TitleTemplate>
            <ResourceAuthorize ResourceKey="user_center_tenant_refresh">
                <TableSearch TDto="SystemTenantDto" @ref="this._tableSearch" OnSearch="OnTableSearch" Settings="_tableSearchSettings" CustomLocalizer="Localizer" />
            </ResourceAuthorize>
            <Row>
                <AntDesign.Col Span="8">
                    <ResourceAuthorize ResourceKey="user_center_tenant_delete_selected">
                        <Button Type="@ButtonType.Primary" Icon="@IconType.Outline.Delete" Danger OnClick="OnClickDeletes" Loading="_deletesBtnLoading">
                            @Localizer[nameof(SharedLocalResource.DeleteSelected)]
                        </Button>
                    </ResourceAuthorize>
                </AntDesign.Col>
                <AntDesign.Col Span="16" Style="text-align:right">
                    <Space>
                        <ResourceAuthorize ResourceKey="user_center_tenant_add">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="@IconType.Outline.Plus" OnClick="OnClickAdd">
                                    @Localizer[nameof(SharedLocalResource.Add)]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                        <ResourceAuthorize ResourceKey="user_center_tenant_refresh">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="@IconType.Outline.Reload" OnClick="ReLoadTable">
                                    @Localizer[nameof(SharedLocalResource.Refresh)]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                    </Space>
                </AntDesign.Col>
            </Row>
        </TitleTemplate>
        <ColumnDefinitions>
            <Selection Key="@(model.Id.ToString())" Hidden="@_userUnauthorizedResources["user_center_tenant_delete_selected"]" />
            <Column @bind-Field="@model.Id" Filterable >
                <GuidView Value="@model.Id"></GuidView>
              </Column>
            <Column @bind-Field="@model.Name" Filterable />
            <Column @bind-Field="@model.Email" Filterable />
            <Column @bind-Field="@model.Tel" Filterable />
            <Column @bind-Field="@model.IsLocked" Filterable>
                <ResourceAuthorize ResourceKey="user_center_tenant_lock">
                    <Authorized>
                        <Switch @bind-Value="@model.IsLocked" OnChange="e=>OnChangeIsLocked(model,e)" Loading="_lockBtnLoading[model]"></Switch>
                    </Authorized>
                    <NotAuthorized>
                        <TagYesNo Yes="model.IsLocked"></TagYesNo>
                    </NotAuthorized>
                </ResourceAuthorize>
            </Column>
            <Column @bind-Field="@model.CreatedTime" Format="@ClientConstant.DateTimeFormat" Sortable DefaultSortOrder="@SortDirection.Descending" />
            <ActionColumn>
                <Space>
                    <ResourceAuthorize ResourceKey="user_center_tenant_set_resource">
                        <SpaceItem>
                            <Tooltip Title="@(Localizer[nameof(SharedLocalResource.BindingResource)])" ArrowPointAtCenter="true">
                                <Button Icon="security-scan" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnEditTenantResourceClick(model)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="user_center_tenant_edit">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(SharedLocalResource.Edit)]" ArrowPointAtCenter="true">
                                <Button Icon="@IconType.Outline.Edit" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnClickEdit(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="user_center_tenant_detail">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(SharedLocalResource.Detail)]" ArrowPointAtCenter="true">
                                <Button Icon="@IconType.Outline.Eye" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnClickDetail(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="user_center_tenant_copy">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(SharedLocalResource.Copy)]" ArrowPointAtCenter="true">
                                <Button Icon="@IconType.Outline.Copy" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="() => CopyNewTenant(model.Id)" Loading="copyTenantLoading[model.Id]"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="user_center_tenant_delete">
                        <SpaceItem>
                            <Tooltip Title="@Localizer[nameof(SharedLocalResource.Delete)]" ArrowPointAtCenter="true">
                                <Button Icon="@IconType.Outline.Delete" Type="@ButtonType.Primary" Danger OnClick="()=>OnClickDelete(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                </Space>
            </ActionColumn>
        </ColumnDefinitions>
    </Table>
</div>